package com.whfc.iot.session;

import io.netty.channel.Channel;

import java.util.Collection;
import java.util.Map;

/**
 * @Description: session管理器
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/7/16 15:41
 */
public interface SessionManager {

    /**
     * 创建session
     *
     * @param deviceType
     * @param deviceId
     * @param channel
     * @return
     */
    Session createSession(Integer deviceType, Integer deviceId, Channel channel);

    /**
     * 创建session
     *
     * @param deviceType
     * @param deviceSn
     * @param channel
     * @return
     */
    Session createSession(Integer deviceType, String deviceSn, Channel channel);

    /**
     * 删除session
     *
     * @param channelId
     */
    void delete(String channelId);

    /**
     * 根据终端ID获取session
     *
     * @param deviceId
     * @return
     */
    Session getSessionByDeviceId(Integer deviceId);

    /**
     * 获取session
     *
     * @param deviceSn
     * @return
     */
    Session getSessionByDeviceSn(String deviceSn);

    /**
     * 根据channelId获取session
     *
     * @param channelId
     * @return
     */
    Session getSessionByChannelId(String channelId);

    /**
     * 查询所有在线终端
     *
     * @return
     */
    Map<String, String> getAllOnlineDevice();
}
